<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
use App\Http\Model\User;
use App\Lib\Search;
use App\Lib\Publisher;
use App\Lib\SendSms;

class CheckPlatformLink extends Command
{
    protected $signature = 'CheckPlatformLink';

    protected $description = '检查服务连接状态';

    public function __construct()
    {
        parent::__construct();
    }

    public function handle()
    {
        //mysql
        echo "\r\n-------mysql-------------\r\n";
        $res = DB::table('user')->first();
        print_r($res);
        echo "\r\n--------------------\r\n";

        //redis
        echo "\r\n-------redis-------------\r\n";
        $res = Redis::GET('CONTENT:CHECK:SWITCH');
        print_r($res);
        echo "\r\n--------------------\r\n";

        //Elasticsearch
        echo "\r\n-------Elasticsearch-------------\r\n";
        $search = new Search();
        $res = $search->searchUser('苏', 0, 1);
        print_r($res);
        echo "\r\n--------------------\r\n";

        //MQ
        echo "\r\n-------MQ-------------\r\n";
        $publishObject = Publisher::getInstance();
        $publishObject->requestData = [
            'queue_route' => 'global.burypoint',
            'data' => [
                'type' => 'invite',
                'properties' => ['account_id'=>10000,'distinct_id'=>'','invite_user'=>''],
            ],
        ];
        $res = $publishObject->publisher();
        print_r($res);
        echo "\r\n--------------------\r\n";


        //验证码
        echo "\r\n-------验证码-------------\r\n";
        $smsObj = new SendSms();
        $res = $smsObj->spSendSingleSms('15532520230', '100000');
        print_r($res);
        echo "\r\n--------------------\r\n";

        return true;
    }

}
